package com.cjm.one.system.config;

import io.minio.MinioClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
@EnableConfigurationProperties(MinioPropertis.class)
public class MinioConfig {
    @Resource
    private  MinioPropertis properties;



    @Bean
    public MinioClient minioClient() {
        log.info("Minio endpointUrl: {}", properties.getEndpointUrl());
        log.info("Minio accessKey: {}", properties.getAccessKey());
        log.info("Minio secretKey: {}", properties.getSecretKey());
        log.info("Minio bucketName: {}", properties.getBucketName());
        return MinioClient.builder()
                .credentials(properties.getAccessKey(), properties.getSecretKey())
                .endpoint(properties.getEndpointUrl())
                .build();
    }
}